import java.util.Locale;

public class Test {
    public static void main(String[] args) {
            long start = System.currentTimeMillis();
            String s = "";
            for (int i = 0; i < 10000; ++i) {
                s += i;
            }
            long end = System.currentTimeMillis();
            System.out.println(end - start);
            start = System.currentTimeMillis();
            StringBuffer sbf = new StringBuffer("");
            for (int i = 0; i < 10000; ++i) {
                sbf.append(i);
            }
            end = System.currentTimeMillis();
            System.out.println(end - start);
            start = System.currentTimeMillis();
            StringBuilder sbd = new StringBuilder();
            for (int i = 0; i < 10000; ++i) {
                sbd.append(i);
            }
            end = System.currentTimeMillis();
            System.out.println(end - start);
        }

        public static void main9 (String[]args){
            String str = "hello world&hello people";
            String[] result = str.split(" |&");
            for (String s : result) {
                System.out.println(s);
            }
            System.out.println("============================");
            String str1 = "hello world hello people";
            String[] result1 = str.split(" ", 2);
            for (String s : result1) {
                System.out.println(s);
            }
        }
        public static void main8 (String[]args){
            String s = String.format("%d-%d-%d", 2024, 6, 1);
            System.out.println(s);
        }
        public static void main7 (String[]args){
            //字符串转数组
            String s1 = "hello";
            char[] ch = s1.toCharArray();
            for (int i = 0; i < ch.length; i++) {
                System.out.println(ch[i]);
            }
            System.out.println("====================");
            //数组转字符串
            String s2 = new String(ch);
            System.out.println(s2);
        }
        public static void main6 (String[]args){
            String s1 = "hello";
            String s2 = "HElLO";
            System.out.println(s1.toUpperCase(Locale.ROOT));
            System.out.println(s2.toLowerCase(Locale.ROOT));
        }

        public static void main5 (String[]args){
            class Student {
                public String name;
                public int age;

                public Student(String name, int age) {
                    this.name = name;
                    this.age = age;
                }

                public String getName() {
                    return name;
                }

                public void setName(String name) {
                    this.name = name;
                }

                public int getAge() {
                    return age;
                }

                public void setAge(int age) {
                    this.age = age;
                }
            }

            //数字转字符串
            String s1 = String.valueOf(1234);
            String s2 = String.valueOf(12.34);
            String s3 = String.valueOf(true);
            String s4 = String.valueOf(new Student("mini", 18));
            System.out.println(s1);
            System.out.println(s2);
            System.out.println(s3);
            System.out.println(s4);
            System.out.println("=============================");
            int a = Integer.parseInt("1234");
            double b = Double.parseDouble("12.34");
            System.out.println(a);
            System.out.println(b);
        }


        public static void main4 (String[]args){
            String s1 = new String("abc");
            String s2 = new String("ac");
            String s3 = new String("ABc");
            String s4 = new String("abcdef");
            System.out.println(s1.compareToIgnoreCase(s2));
            System.out.println(s1.compareToIgnoreCase(s3));
            System.out.println(s1.compareToIgnoreCase(s4));
        }


        public static void main3 (String[]args){
            String s1 = "hello";
            String s2 = "world";
            String s3 = "hello";
            System.out.println(s1.equals(s2));
            System.out.println(s1.equals(s3));

        }
        public static void main2 (String[]args){
            int a = 10;
            int b = 20;
            int c = 10;
            System.out.println(a == b);
            System.out.println(a == c);
            String s1 = "hello";
            String s2 = "world";
            String s3 = new String("hello");
            System.out.println(s1 == s2);
            System.out.println(s1 == s3);

        }
        public static void main1 (String[]args){
            String s1 = "hello,world";

            String s2 = new String("hello,world");

            char[] array = {'h', 'e', 'l', 'l', 'o'};
            String s3 = new String(array);


        }
 }
